package pers.gxm.flyweight;

import java.util.HashMap;
import java.util.Map;

public class BigCharFactory {
    private Map<String,BigChar> pool = new HashMap<>();
    private static BigCharFactory instance  = new BigCharFactory();
    private BigCharFactory(){}

    public static BigCharFactory getInstance(){
        return  instance;
    }

    public synchronized  BigChar getBigChar(char charName){
        BigChar bigChar = pool.get("" + charName);
        if(bigChar == null){
            bigChar = new BigChar(charName);
            pool.put("" + charName,bigChar);
        }
        return bigChar;
    }
}
